<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- <button type="submit" formaction="www.baidu.com">提交</button>
     <input type="text" placeholder="必须写sb"> -->
    <script>
        "use strict";
        function user(name){
        this.name=name;
         //不在这里写方法了，1.浪费空间 2.代码的复用性差
        }
        user.prototype.show=function(){
            console.log(this.name);
        }; //直接在把代码加在原型上
    
        //所以批量写方法这样写,放入到方法里面
        user.prototype={
            constructor:user, //写入到对象的时候，一定要写构造器
          show(){
             console.log(this.name);
          },
          get(){
              console.log("get...");
          }
        }

        //new 对象
        let tw=new user("唐玮");
        tw.show();//唐玮
        tw.get();
        console.log(tw);
    </script>
</body>
</html>